package dbconn

import (
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
	"time"
)

func InitMongoLocalSession(conf bson.M)*mgo.Session{
	dailInfo := &mgo.DialInfo{
		Addrs:[]string{conf["uri"].(string)},
		Direct: false,
		Timeout: time.Second * time.Duration(conf["timeout"].(int)),
		Database: conf["database"].(string),
		Source: conf["source"].(string),
		PoolLimit: conf["pool"].(int),
	}
	session, err := mgo.DialWithInfo(dailInfo)
	if err != nil {
		panic(err.Error())
	}
	session.SetMode(mgo.Monotonic, true)
	return session
}
